package scheduler

import (
	"github.com/zeromicro/go-zero/core/logx"
	"time"
)

// Option 配置函数
type Option func(cron *Cron)

// WithLocation 设置时区
func WithLocation(loc *time.Location) Option {
	return func(cron *Cron) {
		cron.location = loc
	}
}

func WithSeconds() Option {
	return WithParser(NewParser(Second | Minute | Hour | Dom | Month | Dow | Descriptor))
}

// WithParser 自定义解析器
func WithParser(p IScheduleParse) Option {
	return func(cron *Cron) {
		cron.parser = p
	}
}

// WithChain 设置链式调用
func WithChain(wrappers ...WrapperJob) Option {
	return func(cron *Cron) {
		cron.chain = NewChain(wrappers...)
	}
}

// WithLogger 设置日志
func WithLogger(logger logx.Logger) Option {
	return func(cron *Cron) {
		cron.logger = logger
	}
}
